$OpenBSD: patch-kdeprint_cups_cupsdconf2_cupsddialog_cpp,v 1.1 2007/10/06 12:47:20 ajacoutot Exp $
--- kdeprint/cups/cupsdconf2/cupsddialog.cpp.orig	Mon Oct 10 17:06:30 2005
+++ kdeprint/cups/cupsdconf2/cupsddialog.cpp	Sat Oct  6 14:48:54 2007
@@ -44,6 +44,7 @@
 #include <kio/passdlg.h>
 #include <kguiitem.h>
 #include <kprocess.h>
+#include <qprocess.h>
 
 #include <signal.h>
 #include <cups/cups.h>
@@ -69,24 +70,37 @@ extern "C"
 
 int getServerPid()
 {
-	QDir	dir("/proc",QString::null,QDir::Name,QDir::Dirs);
-	for (uint i=0;i<dir.count();i++)
-	{
-		if (dir[i] == "." || dir[i] == ".." || dir[i] == "self") continue;
-		QFile	f("/proc/" + dir[i] + "/cmdline");
-		if (f.exists() && f.open(IO_ReadOnly))
+	#if defined(__OpenBSD__)
+		QProcess *proc = new QProcess();
+		proc->addArgument("pgrep");
+		proc->addArgument("cupsd");
+		proc->start();
+		while (proc->isRunning()); //Wait for process to exit
+		QString pidString = proc->readLineStdout();
+		bool ok;
+		int pid = pidString.toInt(&ok);
+		if (ok) return pid;
+		return (-1);
+	#else
+		QDir	dir("/proc",QString::null,QDir::Name,QDir::Dirs);
+		for (uint i=0;i<dir.count();i++)
 		{
-			QTextStream	t(&f);
-			QString	line;
-			t >> line;
-			f.close();
-			if (line.right(5) == "cupsd" ||
-			    line.right(6).left(5) == "cupsd")	// second condition for 2.4.x kernels
-								// which add a null byte at the end
-				return dir[i].toInt();
+			if (dir[i] == "." || dir[i] == ".." || dir[i] == "self") continue;
+			QFile	f("/proc/" + dir[i] + "/cmdline");
+			if (f.exists() && f.open(IO_ReadOnly))
+			{
+				QTextStream	t(&f);
+				QString	line;
+				t >> line;
+				f.close();
+				if (line.right(5) == "cupsd" ||
+				line.right(6).left(5) == "cupsd")	// second condition for 2.4.x kernels
+									// which add a null byte at the end
+					return dir[i].toInt();
+			}
 		}
-	}
-	return (-1);
+		return (-1);
+	#endif
 }
 
 const char* getPassword(const char*)
